<?php

class RatingUpdateManager
{
	public static function AddRatingUpdate($by_user, $to_user, $accurate, $creative, $critical, $friendly, $gooder, $helpful, $trustworthy, $comment)
	{
		$bean = R::dispense('ratingupdate');
		$bean->by_user = $by_user;
		$bean->to_user = $to_user;
		$bean->when_datetime = date('y.m.d H:i:s');
		$bean->accurate = $accurate;
		$bean->creative = $creative;
		$bean->critical = $critical;
		$bean->friendly = $friendly;
		$bean->gooder = $gooder;
		$bean->helpful = $helpful;
		$bean->trustworthy = $trustworthy;
		$bean->comment = $comment;
		R::store($bean);
	}
	
	public static function GetRatingUpdatesForUser($user, $page = 0)
	{
		return aa2oa(R::getAll('SELECT * FROM ratingupdate WHERE to_user=\'' . $user . '\' ORDER BY when_datetime DESC LIMIT ' . ($page * 20) . ', 20'));
	}
}